profiling and optimizing python code